package tut.mysql.load.loadThread;

import tut.mysql.db.Db;

public class InsertCtl implements Runnable {

	int maxQueries = 1; //
	String sql = null;

	Db db = null;

	public InsertCtl(Db db) {
		this.db = db;
	}

	@Override
	public void run() {
		try {
			insert();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void insert() {

		try {
			for (int i = 0; i < maxQueries; i++) {
				try {
					db.executeUpdate(sql);
				} catch (Exception e) {
					e.printStackTrace();
					System.out.println(sql);
					return;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			db.closeConnection();
		}

	}
}
